Add sleep and delay for task handling#115
Merged
LuernOutOfOrder merged 24 commits intodevelopfrom Feb 9, 2026
Merged
Conversation
Add a sleep primitive composed by an asm entry point and a rust function, save the current task context and compute awake tick
Sleep is more a task public API fn than a primitive type
…te dispatch to be aware of that
…rom sleep to this one
… interrupt to awake the blocked task
…to avoid log flooding
… task primitives module
Add a small description, and very trivial documentation on all current primitives types. If I haven't forgot any.
Not working, driving me crazy
The ROM is not really used for now in test mode so it's ok I guess
Testing the invariants from sleep primitive, from the blocked queue and the timer interrupt
Add run queue check for invariants
…e and timing_helpers to documentation Split the primitives documentation to have more separate logic documentation, data structure and timing helpers are not primitives so there's should not be in the primitives documentation.
…eep test behavior Add the info header to primitives task file to keep track of what is tested at this point, update the task sleep test behavior to skipped to not always running it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces kernel task blocking and sleeping primitives, improves documentation, and refines several core kernel mechanisms. The most significant changes are the addition of the
sleepprimitive and blocked task management, as well as new and updated documentation for kernel structures, primitives, and timing helpers.Kernel task blocking and sleeping primitives:
Added a new
sleepprimitive (with supporting assembly and Rust code) to allow tasks to block themselves for a specified number of ticks, updating their state and moving them between ready and blocked queues as appropriate. This includes the newTaskBlockControlenum and changes to theTaskstruct to track block reasons. (src/task/primitives.rs,src/arch/riscv32/asm/sleep.S,src/arch/riscv32/asm/mod.rs,src/task/mod.rs,src/main.rs, [1] [2] [3] [4] [5] [6]Implemented the
task_awake_blockedfunction, which checks the blocked queue and moves tasks back to the ready queue when their sleep duration has elapsed. This is now called from the timer interrupt handler. (src/task/primitives.rs,src/arch/riscv32/traps/handler.rs, [1] [2] [3]Documentation improvements:
Documentation/kernel/data_structure.md,Documentation/kernel/primitives.md,Documentation/kernel/timing_helpers.md, [1] [2] [3]Kernel and scheduling changes:
src/scheduler/mod.rs,src/main.rs, [1] [2]Testing and test infrastructure:
src/tests/suites.rs,src/tests/arch/riscv32/task/task_context.rs, [1] [2] [3]Miscellaneous improvements:
linkers/linker_test_mode.ld, linkers/linker_test_mode.ldL6-R6)Cargo.tomlandsrc/info.rs. [1] [2]src/primitives/ring_buff.rs,src/arch/riscv32/asm/trap_entry.S, [1] [2]These changes lay the groundwork for more advanced task scheduling and blocking mechanisms in the kernel and improve maintainability through better documentation and testing.